package com.tuweiya.study.springmvc002.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Mr_tu
 * @Date: Create in 12:56 2018/6/8
 * @Description: 日志controller
 *  commons-logging
 *      |- 采用log4j实现具体的日志接口
 */
@Api(tags = "LogController", description = "日志框架测试接口")
@RestController
@RequestMapping(value = "/log")
public class LogController {
    private static Log logger = LogFactory.getLog(LogController.class);

    @GetMapping(value = "/printInfo")
    @ApiOperation(value = "打印info级别的请求")
    public String printInfo(){
        logger.info("The request of /log/printInfo entry LogController.printInfo() method.");
        return "printInfo";
    }

    @GetMapping(value = "printWarn")
    @ApiOperation(value = "打印warn级别的请求")
    public String printWarn(){
        logger.warn("The request of /log/printWarn entry LogController.printWarn() method.");
        return "printWarn";
    }

    @GetMapping(value = "/printError")
    @ApiOperation(value = "打印error级别的请求")
    public String printError(){
        logger.error("The request of /log/printError entry LogController.printError() method.");
        return "printError";
    }

    @GetMapping(value = "printDebug")
    @ApiOperation(value = "打印debug级别的请求")
    public String printDebug(){
        logger.debug("The request of /log/printDebug entry LogController.printDebug() method.");
        return "printDebug";
    }




}
